/**
 *To select a submenu 
 * @param {Object} subTabEle
 */
function subMenuSelected(subTabEle) {
	gSelectSubMenu = subTabEle;
	var appID = subTabEle.getAttribute("id");
	var parentApplicationID = subTabEle.getAttribute("parentAppID");
	system.windows['breadcrum'].gOpenFrom = "submenu";
	if (gselectedSubTab) {
		gselectedSubTab.className = "normal";
	}
	gselectedSubTab = subTabEle;
	gselectedSubTab.className = "selected";
	var targetApplicationDef = cordys.selectXMLNode(gApplicationMenuNode, ".//*[local-name()='Application'][@isFolder='true'][*[local-name()='id']='" + parentApplicationID + "']/*[local-name()='Application'][*[local-name()='id']='" + appID + "']");
	if (targetApplicationDef != null) {
		if (!closeAllOpenedForms() || gIsCloseCallBack)
			return;
		loadSelectedSubMenu();
	}
}

function loadSelectedSubMenu() {
	var appID = gSelectSubMenu.getAttribute("id");
	var parentApplicationID = gSelectSubMenu.getAttribute("parentAppID");
	var targetApplicationDef = cordys.selectXMLNode(gApplicationMenuNode, ".//*[local-name()='Application'][@isFolder='true'][*[local-name()='id']='" + parentApplicationID + "']/*[local-name()='Application'][*[local-name()='id']='" + appID + "']");
	if (system.containers[appID]) {
		system.containers[appID].close();
	}
	if (parentApplicationID != "reports") {
		var data = new Object();
		var properties = new Object();
		properties.frame = "main";
		properties.isDialogue = false;
		properties.parentProperties = null;
		properties.isPreview = false;
		data.properties = properties;
		data.closeCallBackHandler = loadSelectedTab;
		application.select(targetApplicationDef, data);
	} else {
		if (system.containers["reports"]) {
			system.containers["reports"].applicationWindow.showHistoryPage(targetApplicationDef);
		}
	}
}

/**
 *Open an application 
 */
if(system.containers[appID])
{
system.containers[appID].close();
}
application.select(applicationNode); 